import cv2
import numpy as np

max_threshold = 200
min_threshold = 10
Ratio = 3
capNo = 0

def callback(object):
    pass


cap = cv2.VideoCapture(capNo)

cap.open(capNo)
capName = ''
if capNo == 0:
    capName = "Camera_Dell"
else:
    capName = "Camera_Logitech"

cv2.namedWindow(capName)
cv2.createTrackbar("threshold", capName, min_threshold, max_threshold, callback)
cv2.createTrackbar("threshold_1", capName, min_threshold, max_threshold, callback)
cv2.createTrackbar("threshold_2", capName, min_threshold, max_threshold, callback)
cv2.createTrackbar("threshold_3", capName, min_threshold, max_threshold, callback)
cv2.createTrackbar("threshold_4", capName, min_threshold, max_threshold, callback)
cv2.createTrackbar("threshold_5", capName, min_threshold, max_threshold, callback)
cv2.createTrackbar("threshold_6", capName, min_threshold, max_threshold, callback)
cv2.createTrackbar("threshold_7", capName, min_threshold, max_threshold, callback)
cv2.createTrackbar("threshold_8", capName, min_threshold, max_threshold, callback)
while cap.isOpened():
    flag, frame = cap.read()
    # cv2.imshow(capName, frame)
    if not flag:
        break

    key_pressed = cv2.waitKey(100)
    print("key >", key_pressed)
    threshold = cv2.getTrackbarPos("threshold", capName)
    threshold_1 = cv2.getTrackbarPos("threshold_1", capName)
    threshold_2= cv2.getTrackbarPos("threshold_2", capName)
    threshold_3= cv2.getTrackbarPos("threshold_3", capName)
    threshold_4= cv2.getTrackbarPos("threshold_4", capName)
    threshold_5= cv2.getTrackbarPos("threshold_5", capName)
    threshold_6= cv2.getTrackbarPos("threshold_6", capName)
    threshold_7= cv2.getTrackbarPos("threshold_7", capName)
    threshold_8= cv2.getTrackbarPos("threshold_8", capName)
    frame = cv2.Canny(frame, threshold, threshold_1*Ratio)
    frame = np.dstack((frame, frame, frame))
    cv2.putText(frame, "Dell", (threshold_2, threshold_3), cv2.FONT_HERSHEY_PLAIN, threshold_4, (threshold_5, threshold_6, threshold_7), threshold_8)
    cv2.moveWindow(capName, 0, 0)
    cv2.imshow(capName, frame)
    if key_pressed == 27:
        break

cap.release()

cv2.destroyAllWindows()
